import { reactive } from "vue";

export const useTabbar = (callback?: (index: number) => void) => {
  const state = reactive({
    actived: 0
  });
  
  // swpier变化事件
  const onSwipierChange = (ev: any) => {
    state.actived = ev.detail.current;
    callback && callback(state.actived);
  }
  
  // 头部点击
  const onTabbarHeaderChange = (index: number) => {
    state.actived = index;
    callback && callback(state.actived);
  }

  return {
    tabbarState: state,
    onSwipierChange,
    onTabbarHeaderChange
  }
}
